# 利用浅拷贝生成树形菜单
def get_children_list(ser_data, s_tree=None):
    for index, i in enumerate(ser_data):
        if s_tree:
            ser_data[index]['value'] = i['id']
            if 'title' in i:
                ser_data[index]['label'] = i['title']
            else:
                ser_data[index]['label'] = i['name']
        for j in ser_data:
            if i['id'] == j['pid']:
                if 'children' not in ser_data[index].keys():
                    ser_data[index]['children'] = []
                ser_data[index]['children'].append(j)
    res = [item for item in ser_data if not item['pid']]
    return res


# 利用浅拷贝生成下拉框
def get_pid_list(ser_data):
    pid_list = []
    for item in ser_data:
        temp = dict()
        temp['id'] = item['id']
        temp['value'] = item['id']
        temp['pid'] = item['pid']
        temp['label'] = item['name']
        pid_list.append(temp)
    return get_children_list(pid_list)
